package com.shexianyu.medium;

public class BulbSwitch {

    public static int bulbSwitch(int n) {

        return (int) Math.sqrt(n + 0.5);
    }
    /**
     * 分析
     * n = 3
     * round1   1 1 1
     * round2   1 0 1
     * round3   1 0 0
     * n = 4
     * round1   1 1 1 1
     * round2   1 0 1 0
     * round3   1 0 0 0
     * round4   1 0 0 1
     * n = 5
     * round1   1 1 1 1 1
     * round2   1 0 1 0 1
     * round3   1 0 0 0 1
     * round4   1 0 0 1 1
     * round5   1 0 0 1 0
     * n = 9
     * round1   1 1 1 1 1 1 1 1 1
     * round2   1 0 1 0 1 0 1 0 1
     * round3   1 0 0 0 1 1 1 0 0
     * round4   1 0 0 1 1 1 1 1 0
     * round5   1 0 0 1 0 1 1 1 0
     * round6   1 0 0 1 0 0 1 1 0
     * round7   1 0 0 1 0 0 0 1 0
     * round8   1 0 0 1 0 0 0 0 0
     * round9   1 0 0 1 0 0 0 0 1
     */
}
